<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * Smarty {restaurant_type_3} function plugin
 * @param array|null $params
 * @param Smarty $smarty
 */
function smarty_function_restaurant_type_3($params, $smarty) {
    if (!isset($params)) {
        return ;
    }

    if (isset($params['limit'])) {
        $limit = $params['limit'];
    } else {
        $limit = 4;
    }

    $filters = array('limit' => $limit);
    $smarty->CI->load->model('restaurant/restaurant_model');
    $data = $smarty->CI->restaurant_model->get_restaurants($filters);
    if (!$data) {
        return '';
    }

    $html = '';
    foreach ($data as $item) {
        $html .= "<div class='items'>
                    <div class='items-photo'>
                        <a href='{$item[link]}'>
                        <img src='{$item[image4]}' alt='{$item[name]}' title='{$item[name]}' width='200' height='125'></a>
                    </div>
                    <div class='items-name'>
                        <h3><a href='{$item[link]}' title='{$item[name]}'>{$item[name]}</a></h3>
                    </div>
                    <div class='items-address'>
                        <span title='{$item[name]}'>{$item[address]}, {$item[pref_name]}</span>
                    </div>
                    <div class='items-stats2'>
                         544 đang xem | <a href='javascript:void(0)' class='restaurant-reviews-link stats-review' title='bình luận' resid='40982'>6 bình luận</a>
                    </div>
                </div>";
    }
    return $html;
}
